package com.framework.buss.word.controller;

import com.framework.buss.word.model.TemplateFile;
import com.framework.buss.word.service.IMonthReportService;
import com.framework.common.domain.ResultData;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/report/month")
@ApiOperation("桥梁月报告")
public class MonthReportController {
    @Autowired
    private IMonthReportService monthReportService;

    @ApiOperation("前端根据模板导出报告")
    @GetMapping(value = "/export")
    public void export(HttpServletResponse response, Map<String, String> params) {
        monthReportService.export(response, params);
    }

    @ApiOperation("前端上传模板")
    @PostMapping(value = "/import")
    public ResultData<?> importTemplate(@RequestParam("file") MultipartFile file, TemplateFile fileInfo) {
        return monthReportService.importTemplate(file, fileInfo);
    }

}
